<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">

    <title>{block name='title'}{$pageTitle?:'星数引擎'}{/block}</title>
    <meta name="keywords" content="{block name='keywords'}{$websiteSets['keywords']}{/block}">
    <meta name="description" content="{block name='description'}{$websiteSets['description']}{/block}">
    <link rel="shortcut icon" href="{if !empty($websiteSets['logo'])}{:tomedia($websiteSets['logo'])}{else}favicon.ico{/if}">

    {block name='baseCss'}
    <link rel="stylesheet" href="__ADMIN_COMPONENT__/bootstrap/bootstrap.min.css">

    <link href="__ADMIN_COMPONENT__/animate/animate.css" rel="stylesheet">

    <!--商城icon 后期将作废-->
    <link rel="stylesheet" type="text/css" href="__ADMIN_FONTS__/shop/iconfont.css?v=20170503">
    <script src="__ADMIN_FONTS__/shop/iconfont.js"></script>

    <!--原始样式-->
    <link rel="stylesheet" href="__ADMIN_CSS__/upload.css?t=20241122">
    <link rel="stylesheet" href="__ADMIN_CSS__/common.css?t=20241122">

    <!--后台装修-->
    <link href="__ADMIN_CSS__/admin.css?v=4.1.0" rel="stylesheet">
    {/block}

    {block name='baseFont'}
    <link href="__ADMIN_FONTS__/awesome/font-awesome.min.css?v=4.7.0" rel="stylesheet">
    {/block}

    <script type="text/javascript" src="__ADMIN_COMPONENT__/jquery/jquery-1.11.1.min.js"></script>

    {block name='baseScript'}
    <script>var require = {urlArgs: 'v=20211031'};</script>
    <script type="text/javascript">
        if (navigator.appName === 'Microsoft Internet Explorer') {
            if (navigator.userAgent.indexOf("MSIE 5.0") > 0 || navigator.userAgent.indexOf("MSIE 6.0") > 0 || navigator.userAgent.indexOf("MSIE 7.0") > 0) {
                alert('您使用的 IE 浏览器版本过低, 推荐使用 Chrome 浏览器或 IE8 及以上版本浏览器.');
            }
        }

        window.sysinfo = {
            'uniacid': '{$isSystem ? 0 :$uniacid}',
            'uid': '{$uid}',
            'siteroot': '{$siteRoot}',
            'siteurl': '{$iaRoot?$iaRoot:""}',
            'attachurl': '{$attachUrl}',
            'module': '{$module}',
            'client': '{$clientServiceName}',
        };
    </script>

    <script type="text/javascript" src="__ADMIN_JS__/web/util.js"></script>
    <!-- <script type="text/javascript" src="__ADMIN_COMPONENT__/bootstrap/bootstrap.min.js"></script> -->
    <script type="text/javascript" src="__ADMIN_JS__/web/common.min.js"></script>
    <script type="text/javascript" src="__ADMIN_JS__/require.js"></script>
    <script src="__ADMIN_JS__/config.js"></script>

    <script>
        require(['jquery', 'jquery.gcjs', 'init', 'tip']);
        // require(['jquery.gcjs', 'init', 'tip']);

        // 加载tip提示组件
        // require(['tip'], function () {
        // tip.msgbox.suc("登录成功");
        // tip.confirm("登录成功");
        // util.message("验证错误", '', 'error')
        // util.message("验证正确", '', 'success')
        // });
    </script>
    {/block}
</head>
<style>
    .wb-container {
        margin: 0 0 0 130px;
    }

    .wb-nav ~ .wb-subnav ~ .wb-container {
        margin-right: 0;
    }

    .wb-header .dropdown-menu > li {
        width: 100%;
    }

    .wb-header ul li.dropdown.ellipsis {
        min-width: 230px;
    }
</style>
<style>
    .table > thead > tr > td.full, .table > tbody > tr > td.full, .table > tfoot > tr > td.full {
        overflow: hidden;
    }

    tbody tr td {
        position: relative;
    }

    tbody tr .icow-weibiaoti--,tbody tr .icon-weibiaoti-- {
        visibility: hidden;
        display: inline-block;
        color: #fff;
        height: 18px;
        width: 18px;
        background: #e0e0e0;
        text-align: center;
        line-height: 18px;
        vertical-align: middle;
    }

    tbody tr:hover .icow-weibiaoti--,tbody tr:hover .icon-weibiaoti-- {
        visibility: visible;
    }

    tbody tr .icow-weibiaoti--.hidden,tbody tr .icon-weibiaoti--.hidden {
        visibility: hidden !important;
    }
</style>
<style>
    #bg-bk {
        position: absolute;
        right: 30px;
        bottom: 30px;
        display: none;
        overflow: hidden;
        width: 700px;
        height: 400px;
        background-color: rgba(0, 0, 0, .6);
        z-index: 1000;
    }

    #bg-content-bg {
        position: relative;
        display: flex;
        margin: 0 auto;
        height: 100%;
        max-width: 960px;
        min-width: 300px;
        text-align: center;
        flex-direction: column;
        justify-content: center
    }

    .overlay {
        width: 100%;
        height: 100%;
        position: fixed;
        z-index: -1;
        top: 0;
        left: 0;
    }

    .enlarge-image {
        display: flex;
        width: 100%;
        height: 100%;
        flex-direction: column;
        justify-content: center
    }

    .img {
        position: absolute;
        left: 10%;
        width: 80%;
        max-height: 90%;
        cursor: move;
        object-fit: contain;
    }

    .rotate-btn {
        position: absolute;
        top: 20px;
        right: 80px;
        z-index: 999999999999999999999999;
        width: 36px;
        height: 36px;
        color: #fff;
        font-size: 40px;
        cursor: pointer;
        border: 1px solid #fff;
        border-radius: 100%;
        text-align: center;
        line-height: 46px;
    }

    .close-bk {
        position: absolute;
        top: 20px;
        right: 20px;
        z-index: 999999999999999999999999;
        width: 36px;
        height: 36px;
        color: #fff;
        font-size: 26px;
        cursor: pointer;
        border: 1px solid #fff;
        border-radius: 100%;
        text-align: center;
        line-height: 30px;
    }

    .close-bk:hover {
    }

    .no-scroll {
        overflow: hidden;
    }
</style>
<style>
    .text-more{
        margin-left: 10px !important;
    }
</style>
{block name='style'}{/block}
<!-- 结 构 代 码 -->
<body>

{block name='header'}{/block}
{block name='menus'}{/block}

<div class="wb-container">
    {if in_array($userInfo['role'],['owner','manager','operator'])}
        {if !$isSystem && !empty($selSystemNav)}
            <div class="page-content" id="iframePage" style="height: 700px;">
                <iframe src="{$selSystemNavUrl}" style="position: absolute; display: block; border: 0; top: 0; left: 0; width: 100%; height: 100%;"></iframe>
            </div>
        {else}
            <div style="padding: 0 20px 30px 20px;box-sizing: border-box;" class="wb-content">
                {block name='content'}{/block}
            </div>
        {/if}
    {else}
        <div style="padding: 0 20px 30px 20px;box-sizing: border-box;" class="wb-content">
            {block name='content'}{/block}
        </div>
    {/if}

    <div id="page-loading">
        <div class="page-loading-inner">
            <div class="sk-three-bounce">
                <div class="sk-child sk-bounce1"></div>
                <div class="sk-child sk-bounce2"></div>
                <div class="sk-child sk-bounce3"></div>
            </div>
        </div>
    </div>

    {block name='copyright'}{/block}
</div>

<!--图片放大 start-->
<div id="bg-bk" style="display: none;">
    <div class="overlay"></div>
    <div class="rotate-btn">*</div>
    <div class="close-bk">×</div>
    <div id="bg-content-bg">
        <div class="enlarge-image" id="enlarge-image"></div>
    </div>
</div>
<!--图片放大 end-->

<script type="text/javascript">
    $(() => {
        $('.magnifier img').each(function () {
            let img = $(this);
            let src = img.attr('src');
            let isNo = img.hasClass('magnifier-no');
            if (!isNo) {
                img.wrap(`<a data-magnify="gallery" style="cursor:pointer;" onclick="showMagnifier('${src}',10)"></a>`);
            }
        });
        $(".overlay").click(() => {
            $("#bg-bk").fadeOut()
            let body = document.querySelector('body');
            body.classList.remove('no-scroll');
        })

        let isOwner = parseInt("{php}echo in_array($userInfo['role'],['owner']) ? 1 : 0;{/php}");
        let isSystem = parseInt("{$isSystem?1:0}");

        if( isOwner === 1 && isSystem === 1 ){
            // 1.验证系统是否授权
            checkSystemAuth();
            async function checkSystemAuth() {
                try {
                    const response = await fetch("{:webUrl('sysset/checkSystemAuth')}");
                    const data = await response.json();
                    let isValid = data.result.isValid;
                    if( !isValid ){
                        require(['tip'], function ($) {
                            tip.confirm("系统检测到授权已到期，请联系官方管理员处理",function(){
                                location.href = "{:webUrl('sysset/auth')}"
                            });
                        });
                    }
                } catch (error) {
                    console.log('Error fetching data:', error);
                }
            }

            // 2.定义一个异步函数 监测系统版本
            let isUpgradeSystemNotice = util.cookie.get('isUpgradeSystemNotice') || 0;
            if( parseInt(isUpgradeSystemNotice) === 0 ){
                checkSystemVersion();
            }
            async function checkSystemVersion() {
                try {
                    const response = await fetch("{:webUrl('sysset/checkVersion')}");
                    const data = await response.json();

                    let isUpgrade = data.result.isUpgrade;

                    if( isUpgrade ){
                        require(['tip'], function ($) {
                            tip.confirm("系统检测到有新版本，请及时更新",function(){
                                util.cookie.set('isUpgradeSystemNotice', 1,3600);
                                location.href = "{:webUrl('sysset/upgrade')}"
                            });
                        });
                    }
                } catch (error) {
                    console.log('Error fetching data:', error);
                }
            }

        }

    })

    // 图片放大
    $(window).keydown(function (e) {
        27 === e.which && ($("#bg-bk").fadeOut(), document.querySelector('body').classList.remove('no-scroll'))
    })

    function showMagnifier(url, multiple = 2.0) {
        let isDown = false;
        let closebk = $(".close-bk")
        let rotateBtn = $(".rotate-btn")
        let bg = $("#bg-bk")
        let step = 1;
        let x, y;
        let l;
        let t;
        let body = document.querySelector('body');
        let rotate = 0;

        $("#enlarge-image").empty()
        $("#enlarge-image").append("<img class='img' src='" + url + "'>")
        let img = document.querySelectorAll(".img")[0];

        body.classList.add('no-scroll');

        bg.fadeIn()

        /* zoom */
        document.onmousewheel = function (e) {
            let isbig = e.wheelDelta;
            if (isbig >= 0) {
                if (step >= multiple) {
                } else {
                    step += 0.1;
                    img.style.transform = "scale(" + step + ") " + (rotate > 0 ? `rotate(${rotate}deg)` : '');
                }
            } else {
                if (step <= 0.7) {
                } else {
                    step -= 0.1;
                    img.style.transform = "scale(" + step + ") " + (rotate > 0 ? `rotate(${rotate}deg)` : '');
                }
            }
        }
        /* zoom */

        img.onmousedown = function (e) {
            e.preventDefault()
            img.style.cursor = "move"
            // console.log(e.offsetX);
            // console.log(img.offsetLeft);
            x = e.clientX;
            y = e.clientY;
            l = img.offsetLeft;
            t = img.offsetTop;
            isDown = true;
        }

        document.onmousemove = function (e) {
            if (isDown == false) {
                return;
            } else {
                let nx = e.clientX;
                let ny = e.clientY;
                //计算移动后的左偏移量和顶部的偏移量
                let nl = nx - (x - l);
                let nt = ny - (y - t);
                img.style.left = nl + 'px';
                img.style.top = nt + 'px';
            }
        }

        img.onmouseup = function () {
            // img.style.cursor = "default"
            isDown = false
        }

        closebk.click(function () {
            bg.fadeOut()
        })
        rotateBtn.click(function () {
            if (rotate >= 360) {
                rotate = 0;
            }
            rotate = rotate + 45;
            img.style.transform = "scale(" + step + ") " + (rotate > 0 ? `rotate(${rotate}deg)` : '');
        })
    }
</script>

<div class="modal fade" id="public_modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
     aria-hidden="true"></div>

<script>
    // 计算页面高度
    let iframePage = document.getElementById('iframePage');
    if (iframePage) {
        let windowHeight = document.body.clientHeight;
        iframePage.style.height = (windowHeight - 145) + 'px';
    }
</script>

<script>
    // 二维码
    $(() => {
        if( typeof require != 'undefined') {
            require(['bootstrap'], function ($) {

                /*添加拖拽功能 start*/
                $(document).on("show.bs.modal", ".modal", function () {
                    require(['jquery.ui'], () => {
                        $(this).draggable({
                            handle: ".modal-header",   // 只能点击头部拖动
                            cursor: 'move',
                        });
                        $(this).css("overflow", "hidden"); // 防止出现滚动条，出现的话，你会把滚动条一起拖着走的
                    })
                });
                /*添加拖拽功能 end*/

                // 鼠标选中弹出信息框
                $("[rel=pop]").popover({
                    trigger: 'manual',
                    placement: 'right',
                    title: $(this).data('title'),
                    html: true,
                    content: $(this).data('content'),
                    animation: false
                }).on("mouseenter", function () {
                    let _this = this;
                    $(this).popover("show");
                    $(this).siblings(".popover").on("mouseleave", function () {
                        $(_this).popover('hide');
                    });
                }).on("mouseleave", function () {
                    let _this = this;
                    setTimeout(function () {
                        if (!$(".popover:hover").length) {
                            $(_this).popover("hide")
                        }
                    }, 100);
                });

                // 防止bootstrap自带的tooltip和popover在模态框中失效
                if( typeof require != 'undefined'){
                    $('[data-toggle="tooltip"]').tooltip("destroy").tooltip({
                        container: $(document.body)
                    });
                    $('[data-toggle="popover"]').popover("destroy").popover({
                        container: $(document.body)
                    });
                }
            });
        }

        if( typeof require != 'undefined') {
            require(['jquery.qrcode'], function () {
                $(".qrcode-box").hover(function () {
                    $(this).children('.qrcode').show().html("").qrcode({
                        render: "canvas",
                        width: 140,
                        height: 140,
                        text: $(this).children('.qrcode').data('url')
                    });
                    $(this).children('.qrcode').append(`<div class="arrow" style="top: 50%;"></div>`)
                }, function () {
                    $(this).children('.qrcode').hide();
                })

                $(".qrcode-info").each(function () {
                    $(this).children('.qrcode').show().html("").qrcode({
                        render: "canvas",
                        width: 140,
                        height: 140,
                        text: $(this).children('.qrcode').data('url')
                    });
                })
            });
        }

        // tab切换
        $('#myTab a').click(function (e) {
            $('#tab').val($(this).attr('href'));
            e.preventDefault();
            $(this).tab('show');
        });

        // 监测搜索表单是否添加了i参数 start
        let $form = $('.table-search');
        let inputExists = $form.find('input[type="hidden"][name="i"]').length > 0;
        if (!inputExists && encodeURIComponent("{$_GET['i']??0}") > 0) {
            $form.prepend('<input type="hidden" name="i" value="' + encodeURIComponent("{$_GET['i']??0}") + '"/>');
        }
        // end
    })
</script>

<!--低分辨率一级导航显示不全问题 start-->
<script>
    let navheight = document.getElementById('navheight');
    let navwidth = document.getElementById('navwidth');
    let vh = document.body.clientHeight;
    let vw = screen.width;

    if (navheight) {
        if (vh < 800) {
            navheight.classList.add("wb-navheight");
        } else {
            navheight.classList.remove("wb-navheight");
        }

        if (vw < 1300) {
            navwidth.classList.add("wb-navwidth");
        }
    }
</script>

<!--低分辨率一级导航显示不全问题 end-->

<script>
    // 模态框
    function ajaxModel(obj) {
        let url = $(obj).data('url');
        let keyboard = $(obj).data('keyboard');
        if (keyboard === undefined) {
            keyboard = true;
        }
        let backdrop = $(obj).data('backdrop');
        if (backdrop === undefined) {
            backdrop = 'static';
        }
        $.get(url, {}, function (html) {
            $("#public_modal").html(html).modal({backdrop: backdrop, keyboard: keyboard, show: true});
        });
    }
</script>

<script>
    if ($('form.form-validate').length <= 0) {
        window.formInited = true;
    }

    // 定义定时器和超时器的引用
    window.formInitTimer = setInterval(function () {
        if (typeof window.formInited !== 'undefined') {
            closeLoading();
        }
    }, 1);

    // 添加 5 秒超时关闭逻辑-
    window.formInitTimeout = setTimeout(function () {
        closeLoading();
    }, 3000);

    // 统一关闭 loading 并清理定时器
    function closeLoading() {
        $('#page-loading').remove();
        clearInterval(window.formInitTimer);
        clearTimeout(window.formInitTimeout);
    }

    // 统一打开 Loading
    function openLoading(maxDelay = 60000) {
        // 判断loadign是否存在
        if ($('#page-loading').length > 0) {
            return;
        }
        $('.wb-container').append(`<div id="page-loading"> <div class="page-loading-inner"> <div class="sk-three-bounce"> <div class="sk-child sk-bounce1"></div> <div class="sk-child sk-bounce2"></div> <div class="sk-child sk-bounce3"></div> </div> </div> </div>`);
        // 超过60秒后，关闭 loading
        let openLoadingTimer = setTimeout(function () {
            clearTimeout(openLoadingTimer);
            closeLoading();
        }, maxDelay);
    }
</script>

<script>
    // 字段排序
    function tableFieldSort(type, order) {
        let sortType = getUrlQueryVariable('sort');
        let url = location.href;

        url = removeUrlQueryParam(url, 'sort');
        url = removeUrlQueryParam(url, 'order');

        if (type) {
            url = url + '&sort=' + type + '&order=' + order
        }
        location.href = url
    }

    // 获取url地址参数
    function getUrlQueryVariable(variable) {
        let query = window.location.search.substring(1);
        let vars = query.split("&");
        for (let i = 0; i < vars.length; i++) {
            let pair = vars[i].split("=");
            if (pair[0] === variable) {
                return pair[1];
            }
        }
        return false;
    }

    // 删除指定参数
    function removeUrlQueryParam(url, param) {
        const queryString = url.split('?')[1];

        if (!queryString) {
            // 如果没有查询字符串，直接返回当前URL
            return url;
        }
        // 使用 URLSearchParams 对象解析查询字符串
        const params = new URLSearchParams(queryString);

        // 删除指定的参数
        params.delete(param);

        // 构造新的查询字符串
        const newQueryString = params.toString();

        // 如果查询字符串为空，返回没有查询字符串的URL
        if (newQueryString === '') {
            return url.split('?')[0];
        }

        // 否则返回新的URL
        return url.split('?')[0] + `?${newQueryString}`;
    }

    function tokenGen(This,length=32) {
        let letters = 'abcdefghijklmnopqrstuvwxyz0123456789';
        let token = '';
        for(let i = 0; i < length; i++) {
            let j = parseInt(Math.random() * (31 + 1));
            token += letters[j];
        }
        $(This).prev().val(token);
    }

    function EncodingAESKeyGen(This,length=43) {
        let letters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
        let token = '';
        for(let i = 0; i < length; i++) {
            let j = parseInt(Math.random() * 61 + 1);
            token += letters[j];
        }
        $(This).prev().val(token);
    }
</script>

{block name='script'}{/block}

</body>

</html>